Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6: Implemented DataHandler class and extract/remove/namelist #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

johannesbulin
Copy link
Collaborator

(See issue #6)

Added support for data pipelines to ifsbench. The main feature is a DataHandler base class that can perform a given action on a working directory. Currently I've implemented:

  • RenameHandler - for moving/renaming/copying files, using regular expressions.
  • NamelistHandler - for modifying namelists.
  • ExtractHandler - for extracting archives.

Talking points / request for feedback:

  • At the moment, nothing in the data pipeline uses the InputFile concept that we've used before (with file hashes and other things). If you think that this should be included, I'd be happy about some suggestions.
  • I am not a big fan of having enums as embedded classes (RenameHandler.RenameMode for example). It's a bit clunky to write but I haven't come up with a better solution.

@FussyDuck
Copy link

FussyDuck commented Dec 16, 2024

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 98.67550% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@a847cbd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
ifsbench/data/datahandler.py 83.33% 1 Missing ⚠️
ifsbench/data/renamehandler.py 97.95% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main       #7   +/-   ##
=======================================
  Coverage        ?   78.15%           
=======================================
  Files           ?       22           
  Lines           ?     1927           
  Branches        ?        0           
=======================================
  Hits            ?     1506           
  Misses          ?      421           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great already!

I left a lot of nitpicky comments but mostly around style and docstrings. Implementation looks mostly good to me and testing is very diligently done!

ifsbench/data/datahandler.py Outdated Show resolved Hide resolved
ifsbench/data/datahandler.py Outdated Show resolved Hide resolved
ifsbench/data/__init__.py Outdated Show resolved Hide resolved
ifsbench/data/extracthandler.py Outdated Show resolved Hide resolved
ifsbench/data/extracthandler.py Outdated Show resolved Hide resolved
mode: `RenameHandler.RenameMode`
Specifies how the renaming is done (copy, move, symlink).

mode: `RenameHandler.RenameMode`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mode: `RenameHandler.RenameMode`
mode: RenameHandler.RenameMode

ifsbench/data/renamehandler.py Outdated Show resolved Hide resolved
ifsbench/data/renamehandler.py Outdated Show resolved Hide resolved
ifsbench/data/renamehandler.py Outdated Show resolved Hide resolved
Comment on lines 18 to 48
@pytest.mark.parametrize('pattern,repl,mode,files_in,files_out', [
(r'file', r'data', RenameHandler.RenameMode.MOVE,
['data/data.txt','data1/data1.txt'],
['data/data.txt','data1/data1.txt'],
),
(r'(?P<name>data[^/]*.txt)', r'new_dir/\g<name>', RenameHandler.RenameMode.COPY,
['data/data.txt','data1/data1.txt'],
['data/data.txt','data1/new_dir/data1.txt', 'data/data.txt','data1/new_dir/data1.txt'],
),
(r'data[^/]*/', r'', RenameHandler.RenameMode.SYMLINK,
['data/data.txt','data1/data1.txt', 'data2/data1.txt'],
None,
),
(r'(?P<name>data[^/]*.txt)', r'newdir/\g<name>', RenameHandler.RenameMode.SYMLINK,
['data/data.txt','data1/data1.txt', 'data2/data1.txt'],
['data/data.txt','data1/data1.txt', 'data2/data1.txt',
'data/newdir/data.txt','data1/newdir/data1.txt',
'data2/newdir/data1.txt'],
),
(r'data[^/]*/', r'', RenameHandler.RenameMode.MOVE,
['data/data.txt','data1/data1.txt', 'data1/data2.txt'],
['data.txt', 'data1.txt', 'data2.txt'],
),
(r'data[12]/', r'data/', RenameHandler.RenameMode.MOVE,
['data/data.txt','data1/data.txt', 'data1/data2.txt'],
['data/data.txt', 'data/data2.txt'],
),
(r'replacement$', r'dummypath', RenameHandler.RenameMode.COPY,
['dummypath/somedata.tar.gz','replacement'],
['dummypath', 'replacement'],
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repl should not be an r-string, right?

Also, if you decide to allow also compiled patterns I would add or convert 1-2 of the parameterisations to use re.compile(r'...') as pattern

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to change this but now it complains about repl strings that contain \g<something>. So I guess that at least some of them should should be r-strings.

Copy link
Collaborator

@mlange05 mlange05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, and aside from the marked docstrings the design is very neat. I agree with all that was said before and look forward to seeing the actual "pipelines" in action.

Will mark only as comment for now, until all of B.'s points are addressed, but looks good to me otherwise.

johannesbulin added a commit to johannesbulin/ifsbench that referenced this pull request Jan 10, 2025
@johannesbulin johannesbulin force-pushed the johannesbulin.datahandler.#6 branch from 65dedfc to 854b655 Compare January 10, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants